Release 10.1A: OpenEdge Development:
Programming Interfaces


Sharing streams among procedures

In some cases, you might want two or more procedures to share the same input or output streams. The following procedures, i-sstrm.p and i-dispho.p, share the same output stream, phonelist. Notice that phonelist is defined as a shared stream in both procedures:

i-sstrm.p
DEFINE NEW SHARED BUFFER xrep FOR salesrep. 
DEFINE NEW SHARED STREAM phonelist. 
OUTPUT STREAM phonelist TO phonefile. 
PAUSE 2 BEFORE-HIDE. 
FOR EACH xrep: 
  DISPLAY xrep WITH FRAME repname 
    TITLE "Creating report for " 2 COLUMNS CENTERED ROW 10. 
  DISPLAY STREAM phonelist xrep WITH 2 COLUMNS STREAM-IO. 
  RUN i-dispho.p. 
END. 

The i-sstrm.p procedure defines a NEW SHARED STREAM called phonelist. The procedure sends the output from the phonelist stream to a file called phonefile. The procedure also calls the i-dispho.p procedure:

i-dispho.p
DEFINE SHARED BUFFER xrep FOR salesrep. 
DEFINE SHARED STREAM phonelist. 
FOR EACH customer OF xrep BY state: 
  DISPLAY STREAM phonelist cust-num name city state phone 
          WITH NO-LABELS STREAM-IO. 
END. 

The i-dispho.p procedure defines the SHARED STREAM phonelist, and displays the information from that stream on the screen. (It is more efficient to place the FOR EACH and DISPLAY statements in the i-sstrm.p procedure. They are in a separate procedure here to illustrate shared streams.)

Note: You cannot define or access shared streams in a persistent procedure. If you do, Progress returns a run-time error when you create the persistent procedure. For more information, see the chapter on persistent procedures in OpenEdge Development: Progress 4GL Handbook .

Sharing streams is much like sharing variables:


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095